<?php
	
	$chat_session_object = new ElggObject();
	$chat_session_object->subtype = "elggchat_session";
	$chat_session_object->access_id = 2;
	$chat_session_object->save();
	
	$chat_session_guid = $chat_session_object->getGUID();
	
	// session (guid one) has member user (guid two)
	add_entity_relationship( $chat_session_guid,"elggchat_session_member", get_loggedin_userid()); 
	
	$invite = get_input("invite");
	if($invite){
		// you can only invite users :)
		if(get_user ($invite)){
			add_entity_relationship( $chat_session_guid,"elggchat_session_member_invite", $invite); 
		}
	}
	echo $chat_session_guid;
?>

